﻿using System;
using System.Windows.Data;

namespace AddressManager.Common.XAML.Converter
{
    public class BirthdayConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var valueToConvert = (DateTime)value;

            return valueToConvert.ToShortDateString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var valueToConvertBack = (string)value;

            return DateTime.Parse(valueToConvertBack);
        }
    }
}